﻿using PhotoKiosk.Model;
using PhotoKiosk.ViewModel.Helpers;
using System.Windows.Input;

namespace PhotoKiosk.ViewModel.UserControls
{
    public class PaperFrameButtonViewModel : ViewModelBase
    {
        private PaperFrame m_aperFrame;

        public PaperFrameButtonViewModel(PaperFrame i_paperFrame)
        {
            m_aperFrame = i_paperFrame;
        }

        public string Text
        {
            get
            {
                return m_aperFrame.ToString();
            }
        }

        #region Select Command
        private DelegateCommand m_selectCommand;
        public ICommand SelectCommand
        {
            get
            {
                if (m_selectCommand == null)
                {
                    m_selectCommand = new DelegateCommand(param => this.selectCommandExecute(), param => this.selectCommandCanExecute());
                }
                return m_selectCommand;
            }
        }

        private bool selectCommandCanExecute()
        {
            return true;
        }

        private void selectCommandExecute()
        {
            if (OnClick != null)
            {
                OnClick(m_aperFrame);
            }
            IsSelected = true;
        }

        private bool m_isSelected = false;
        public bool IsSelected
        {
            get
            {
                return m_isSelected;
            }
            set
            {
                m_isSelected = value;
                OnPropertyChanged("IsSelected");
            }
        }
        #endregion

        #region OnClick Event
        public event ClickHandler OnClick;
        public delegate void ClickHandler(PaperFrame i_paperFrame);
        #endregion
    }
}